<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
    <script src="https://cdn.bootcss.com/vue-router/3.1.3/vue-router.min.js"></script>
    <style>
        a {
            text-decoration: none;
        }
        .router-link-active {
            background-color: #abcdef;
            color: white;
        }
    </style>
</head>
<body>
    <div id="app">

        <router-link to="login">去登录</router-link>
        <router-link to="register">去注册</router-link>

        <router-view></router-view>
    </div>

    <template id="t1">
        <div>
            登录UI
        </div>
    </template>

    <template id="t2">
        <div>
            注册UI
        </div>
    </template>

    <script>

        var loginComponent = {
            template: "#t1"
        };

        var registerComponent = {
            template: "#t2"
        };


        var router = new VueRouter({
            routes: [
                {component: loginComponent, path:"/"},
                {component: loginComponent, path:"/login"},
                {component: registerComponent, path:"/register"},
            ]
        });

        var app = new Vue({
            el: "#app",
            router      // 等价于router:router
        });
    </script>

</body>
</html>